package com.marketing.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.marketing.auth.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

/**
 * 用户数据访问层
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 更新用户最后登录信息
     */
    @Update("UPDATE sys_user SET last_login_time = #{loginTime}, last_login_ip = #{loginIp}, " +
            "login_count = login_count + 1, update_time = #{updateTime} WHERE username = #{username}")
    void updateLastLoginInfo(@Param("username") String username, 
                            @Param("loginTime") LocalDateTime loginTime, 
                            @Param("loginIp") String loginIp,
                            @Param("updateTime") LocalDateTime updateTime);
}